package com.estore.action;

import java.util.List;

import com.estore.info.BrandInfo;
import com.estore.info.ProductInfo;
import com.estore.info.ProfileInfo;
import com.estore.info.SubCatInfo;
import com.estore.manager.ProductManager;
import com.estore.manager.ProfileManager;
import com.estore.model.ProductModel;
import com.estore.model.ProfileModel;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class StartupAction extends ActionSupport implements
		ModelDriven<ProductModel> {
	private static final long serialVersionUID = 6535875941579248647L;
	private ProductManager productManager;
	private ProfileManager profileManager;
	private List<SubCatInfo> listSubcat;
	private List<ProductInfo> listAllProduct;
	private ProductModel productModel = new ProductModel();
	private ProfileModel profileModel = new ProfileModel();

	public String startup() {
		listSubcat = productManager.listSubCatInfo();
		List<ProductInfo> list12NewProduct = productManager
				.getTop12NewProduct();
		productModel.setList12NewProduct(list12NewProduct);

		// if (productModel.getCatID() != null) {
		// listAllProduct =
		// productManager.getListProduct(productModel.getCatID());
		// } else {
		// listAllProduct = productManager.getListAllProduct();
		// }
		return "success";
	}

	// list all profile
	public String adminstartup() {
		List<ProfileInfo> listprofileinfo = profileManager.getListProfileInfo();
		if (listprofileinfo != null) {
			profileModel.setListprofileinfo(listprofileinfo);
		}
		return "success";
	}

	public String getProductByCat() {
		System.out.println(productModel.getCatID());
		listSubcat = productManager.listSubCatInfo();
		if (productModel.getCatID() != null) {
			listAllProduct = productManager.getListProduct(productModel
					.getCatID());
		} else {
			listAllProduct = productManager.getListAllProduct();
		}
		return "success";
	}

	public List<SubCatInfo> getListsubcat() {
		return listSubcat;
	}

	public void setListsubcat(List<SubCatInfo> listsubcat) {
		this.listSubcat = listsubcat;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public ProductManager getProductManager() {
		return productManager;
	}

	public void setProductManager(ProductManager productManager) {
		this.productManager = productManager;
	}

	public ProfileManager getProfileManager() {
		return profileManager;
	}

	public void setProfileManager(ProfileManager profileManager) {
		this.profileManager = profileManager;
	}

	public List<SubCatInfo> getListSubcat() {
		return listSubcat;
	}

	public void setListSubcat(List<SubCatInfo> listSubcat) {
		this.listSubcat = listSubcat;
	}

	public List<ProductInfo> getListAllProduct() {
		return listAllProduct;
	}

	public void setListAllProduct(List<ProductInfo> listAllProduct) {
		this.listAllProduct = listAllProduct;
	}

	public ProductModel getProductModel() {
		return productModel;
	}

	public void setProductModel(ProductModel productModel) {
		this.productModel = productModel;
	}

	public ProfileModel getProfileModel() {
		return profileModel;
	}

	public void setProfileModel(ProfileModel profileModel) {
		this.profileModel = profileModel;
	}

	@Override
	public ProductModel getModel() {
		// TODO Auto-generated method stub
		return null;
	}

}
